﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DualPlaneFR4Paster.Migrations
{
    public partial class changerelationdatabase : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MPcs_MProducts_MProductId",
                table: "MPcs");

            migrationBuilder.DropIndex(
                name: "IX_MPcs_MProductId",
                table: "MPcs");

            migrationBuilder.DropColumn(
                name: "MProductId",
                table: "MPcs");

            migrationBuilder.RenameColumn(
                name: "Id",
                table: "MProducts",
                newName: "ProductId");

            migrationBuilder.AddColumn<int>(
                name: "MProductProductId",
                table: "MPcs",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "MProductProductId1",
                table: "MPcs",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "ProductId",
                table: "MPcs",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateIndex(
                name: "IX_MPcs_MProductProductId",
                table: "MPcs",
                column: "MProductProductId");

            migrationBuilder.CreateIndex(
                name: "IX_MPcs_MProductProductId1",
                table: "MPcs",
                column: "MProductProductId1");

            migrationBuilder.AddForeignKey(
                name: "FK_MPcs_MProducts_MProductProductId",
                table: "MPcs",
                column: "MProductProductId",
                principalTable: "MProducts",
                principalColumn: "ProductId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_MPcs_MProducts_MProductProductId1",
                table: "MPcs",
                column: "MProductProductId1",
                principalTable: "MProducts",
                principalColumn: "ProductId",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MPcs_MProducts_MProductProductId",
                table: "MPcs");

            migrationBuilder.DropForeignKey(
                name: "FK_MPcs_MProducts_MProductProductId1",
                table: "MPcs");

            migrationBuilder.DropIndex(
                name: "IX_MPcs_MProductProductId",
                table: "MPcs");

            migrationBuilder.DropIndex(
                name: "IX_MPcs_MProductProductId1",
                table: "MPcs");

            migrationBuilder.DropColumn(
                name: "MProductProductId",
                table: "MPcs");

            migrationBuilder.DropColumn(
                name: "MProductProductId1",
                table: "MPcs");

            migrationBuilder.DropColumn(
                name: "ProductId",
                table: "MPcs");

            migrationBuilder.RenameColumn(
                name: "ProductId",
                table: "MProducts",
                newName: "Id");

            migrationBuilder.AddColumn<int>(
                name: "MProductId",
                table: "MPcs",
                type: "INTEGER",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_MPcs_MProductId",
                table: "MPcs",
                column: "MProductId");

            migrationBuilder.AddForeignKey(
                name: "FK_MPcs_MProducts_MProductId",
                table: "MPcs",
                column: "MProductId",
                principalTable: "MProducts",
                principalColumn: "Id");
        }
    }
}
